<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./dhs-report-web/dist/dhs_report.umd.js"></script>
</head>

<body>

    <button id="print">打印</button>
    <button id="show"> 预览</button>
    <button id="export"> 导出pdf</button>
    <button id="design"> 设计</button>
    <button id="imagepath"> 获取本地图片路径</button>
    <script>
        var DHS = window.dhsReport ||{}

        document.querySelector("#imagepath").addEventListener('click', () => {
            DHS.dhs_imagepath((data)=>{
                console.log("===========",data)
                alert(data)
            })
        })


        document.querySelector("#show").addEventListener('click', () => {
            const db = {
                "db1": {
                    head: ["c1"],
                    detail: [
                        {
                            c1: ""
                        }
                    ]
                }
            }
            DHS.dhs_show(db, "",[{fileName:"1.png",fileUrl:"https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64"}])
        })

        document.querySelector("#print").addEventListener('click', () => {
            const db = {
                "db1": {
                    head: ["c1"],
                    detail: [
                        {
                            c1: ""
                        }
                    ]
                }
            }
            DHS.dhs_print(db, "", 1,[{fileName:"1.png",fileUrl:"https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64"}])
        })
        document.querySelector("#design").addEventListener('click', () => {

            const str = Array(4).fill('1').join('');

            const db = {
                "db1": {
                    head: ["c1"],
                    detail: [
                        {
                            c1: str
                        }
                    ]
                }
            }
            //    console.log(str);
            DHS.dhs_design(db, "", (data, ctx) => {


                console.log("======= ctx.success()============");
                ctx.success();

            })
        })

        document.querySelector("#export").addEventListener('click', () => {

            const db = {
                "db1": {
                    head: ["c1"],
                    detail: [
                        {
                            c1: ""
                        }
                    ]
                }
            }
            DHS.dhs_exportpdf(db, "", (data, ctx) => {
                console.log("======= ctx.success()============");

                ctx.success();
            })
        })

    </script>
</body>

</html>